''' 
创建字典
dic = {}    必须先创建，否则报错
div[key] = value
'''

dic = {}
dic['ang'] = 5
dic['bao'] = 15
dic['cong'] = 75
dic['deng'] = 98
print(dic)

''' 
查找元素
dic[key]
dic.get(key)
'''

print("bao的页码是： %d" % dic['bao'])
print("get()方法查找元素")
print("cong的页码是： %d" % dic.get('cong'))

''' 
修改元素
dic[key] = value
'''

print("deng 的错误页码是： %d" % dic['deng'])
dic['deng'] = 94
print("新的拼音字典为： %s" % str(dic))

''' 
删除元素
del dic[key]
'''

print("删除deng前的拼音字典为： %s" % str(dic))
del dic['deng']
print("删除deng后的拼音字典为： %s" % str(dic))

''' 
遍历字典元素
for xxx in aaa

items() 获取每一项的键值对
keys()  获取字典中所有的key
values()    获取字典中所有的value
'''

for item in dic:
    print(item)

for item in dic.items():
    print(item)

for key in dic.keys():
    print(key)

for value in dic.values():
    print(value)